﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Text;
using System.Text.RegularExpressions;
using System.Web.UI;



/// <summary>
/// Summary description for Thuvien
/// </summary>
public class Thuvien
{
    //cắt một số từ cho các nội dung 
	public static string CatTu(string chuoi, int Sotu)
	{
        string kq="";
        try
        {
            kq =chuoi.Substring(0,chuoi.IndexOf(" ", Sotu)) + "...";
        }
        catch (Exception ex)
        {
            kq = chuoi + "...";
        }
        return kq;
	}
    public static string BoDauTiengViet(string str)
    {
        Regex regex = new Regex("\\p{IsCombiningDiacriticalMarks}+");
        string temp = str.Normalize(NormalizationForm.FormD).Trim();
        return regex.Replace(temp, String.Empty)
                    .Replace(",", "-").Replace(".", "-").Replace("!", "")
                    .Replace(";", "-").Replace("/","-")
                    .Replace("%","ptram").Replace('"','-')
                    .Replace('\u0111', 'd').Replace('\u0110', 'D')
                    .Replace(' ', '-');     //thêm để dùng cho web khi render trang aspx sang html
    }

    public static void ShowThongBao(string chuoi, Control ctr)
    {
        ScriptManager.RegisterStartupScript(ctr, ctr.GetType(), "redirecMe", "alert('"+ chuoi +"');", true);
    }
}